{{define "user/list.html"}}
<!DOCTYPE html>
<html>
	<head>
        {{template "header"}}
	</head>

	<body>
		<div class="weadmin-nav">
			<span class="layui-breadcrumb">
        <a href="/welcome">首页</a>
        <a href="/admin/user/list">用户管理</a>
        <a><cite>用户列表</cite></a>
      </span>
			<a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
				<i class="layui-icon" style="line-height:30px">ဂ</i></a>
		</div>
		<div class="weadmin-body">
			<div class="layui-row">
				<form id="userQueryForm" class="layui-form layui-col-md12 we-search" lay-filter="userQueryForm" method="get" action="/admin/user/list">
					<div class="layui-inline">
						<label for="L_qorgid" class="layui-form-label">
							所属机构
						</label>
						<div class="layui-input-inline">
							<select name="qorgid" lay-filter="qorgid" id="L_qorgid">
								<option value="">不限</option>
								{{ range .orgOptionList }}
								<option value="{{.Value}}" >{{.Text}}</option>
								{{ end }}
							</select>
						</div>
					</div>

					<div class="layui-inline">
						<input type="text" name="qusername" placeholder="用户名" autocomplete="off" class="layui-input" value="{{ .qusername }}">
					</div>
					<button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
				</form>
			</div>
			<div class="layui-btn-container">
				<button class="fr layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
				<button class="fr layui-btn" onclick="WeAdminEdit('添加用户','/admin/user/add','addUserLayer')"><i class="layui-icon"></i>添加</button>
				<!-- <button class="fr layui-btn" onclick="test()"><i class="layui-icon"></i>测试</button> -->
			</div>
			<table class="layui-table">
				<thead>
					<tr>
						<th>
							<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
						</th>
						<th>序号</th>
						<th>用户名</th>
						<th>所属机构</th>
						<th>性別</th>
						<th>手机号</th>
						<th>邮箱</th>
						<th>加入时间</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
                    {{ range $idx, $v := .dataList }}
					<tr>
						<td><div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id="{{$v.d}}"><i class="layui-icon">&#xe605;</i></div>
						</td>
						<td>{{getSerialNum $idx}}</td>
						<td>{{$v.username}}</td>
						<td>{{$v.orgname}}</td>
						<td>{{if eq "男" $v.gender}}
							<i class="layui-icon we-blue" title="{{$v.gender}}">&#xe662;</i>
							{{else}}
							<i class="layui-icon we-red" title="{{$v.gender}}">&#xe661;</i>{{end}}</td>
						<td>{{$v.phone}}</td>
						<td>{{$v.email}}</td>
						<td>{{sfmtYmd $v.created}}</td>
						<td>{{if $v.state}}已启用{{else}}已禁用{{end}}</td>
						<td class="text-center">
							<a title="详情" onclick="WeAdminShow('详情','/admin/user/detail/{{$v.id}}')" href="javascript:void(0);"><i class="layui-icon">&#xe60b;</i></a>
							&nbsp;&nbsp;
							<a title="编辑" onclick="WeAdminShow('编辑','/admin/user/edit/{{$v.id}}')" href="javascript:void(0);">
								<i class="layui-icon">&#xe642;</i>
							</a>
							&nbsp;&nbsp;

							<a title="分配用户角色" onclick="WeAdminShow('分配用户角色','/admin/user/apply/{{$v.id}}',520,300)" href="javascript:void(0);">
								<i class="layui-icon">&#xe672;</i>
							</a>
							&nbsp;&nbsp;

							{{if eq $v.state "1"}}
							<a onclick="ajaxPatch('/admin/user/eord/{{$v.id}}/0','是否确认禁用该用户?',userRefreshForm)" href="javascript:void(0);" title="禁用">
								<i class="layui-icon">&#xe651;</i>
							</a>
							{{else}}
							<a onclick="ajaxPatch('/admin/user/eord/{{$v.id}}/1','是否确认启用该用户?',userRefreshForm)" href="javascript:void(0);" title="启用">
								<i class="layui-icon">&#xe652;</i>
							</a>
							{{end}}

							&nbsp;&nbsp;
							<a title="删除" onclick="ajaxDelete('/admin/user/del/{{$v.id}}',userRefreshForm)" href="javascript:void(0);">
								<i class="layui-icon">&#xe640;</i>
							</a>
						</td>
                    </tr>
                    {{end}}
				</tbody>
			</table>
			<div class="fr">
				{{._page.PageHtml}}
			</div>
		</div>
		<div id="_flashmsg_" style="display: none;">{{range .flashmsg}}{{.}}{{end}}</div>
    </body>

    {{template "jsfile"}}
	<script type="text/javascript">
		function userRefreshForm(){
			location.replace(location.href);
		}

		layui.extend({
			admin: '/static/js/admin',
		});
		layui.use(['jquery', 'form', 'element', 'admin', 'carousel'], function() {
			var element = layui.element,
				$ = layui.jquery,
				carousel = layui.carousel,
				form = layui.form,
				admin = layui.admin;
			//建造实例
			carousel.render({
				elem: '.weadmin-shortcut'
				,width: '100%' //设置容器宽度
				,arrow: 'none' //始终显示箭头
				,trigger: 'hover'
				,autoplay:false
			});

			form.on("submit(search)",function(data){
				userRefreshForm();
			})

			//弹出
			msg = $("#_flashmsg_").text()
			if(msg){
				layer.msg(msg, {time:3*1000,icon: 1});
			}

			form.val('userQueryForm', {
				"qorgid": '{{.qorgid}}'
			});
		});

		layui.define(['jquery', 'form', 'layer', 'element'], function(exports) {
			var $ = layui.jquery,
				form = layui.form,
				layer = layui.layer,
				element = layui.element;

			window.test = function(){
				layer.msg('测试', {time:3*1000,icon: 1}, function(){
					//layer.alert('测试alert',{icon: 1})
				})
				layer.confirm("是否确定删除？", {icon: 3}, function(index){
					layer.alert('测试alert',{icon: 1})
				})
			}
		})
	</script>

</html>
{{end}}